# DRF的GenericAPIView、Response
# 拓展类子类在generics进行导入
from rest_framework.generics import GenericAPIView, CreateAPIView, ListAPIView, ListCreateAPIView, RetrieveAPIView, \
    UpdateAPIView, DestroyAPIView, RetrieveDestroyAPIView, RetrieveUpdateAPIView, RetrieveUpdateDestroyAPIView
from rest_framework.response import Response
from books.serializers import BookModelSerialzier
from books.models import BookInfo
from rest_framework.throttling import AnonRateThrottle

class BooksView(ListCreateAPIView):
    """
        保存和获取所有
    """

    # 指定查询集属性
    queryset = BookInfo.objects.all()
    # 指定序列化器属性
    serializer_class = BookModelSerialzier

    # 指定限流
    # throttle_classes = [AnonRateThrottle]
    throttle_scope = 'listview'


class BookView(RetrieveUpdateDestroyAPIView):
    # 指定查询集属性
    queryset = BookInfo.objects.all()
    # 指定序列化器属性
    serializer_class = BookModelSerialzier

